package com.study.design.model.createPattern.prototype;

import java.sql.Date;

/**
* @Name: DeepCopySheep
* @Description: 克隆羊，实现深克隆
* @Author: 李超	lc_jack@foxmail.com
* @CreateDate: 2017-2-10 下午7:15:48 
* @Version: V1.0
 */
public class DeepCopySheep implements Cloneable {
	
	private String name ;
	private Date birthday ;
	
	public DeepCopySheep() {
	}

	public DeepCopySheep(String name, Date birthday) {
		this.name = name;
		this.birthday = birthday;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	} 
	
	@Override
	protected Object clone() throws CloneNotSupportedException {
		Object obj = super.clone() ; //浅复制
		//复制对象的属性值，实现深复制
		DeepCopySheep sheep = (DeepCopySheep) obj ;
		sheep.birthday = (Date) this.birthday.clone() ;
		return sheep; 
		
	}
	
}
